<?php
namespace BoxEdu\Widget;
class QuestionsWidget extends \WidgetController
{


    /***********练习******/
    public function subject_exercise($param)
    {
        $examid = $param['examid'];
        $type = $param['type'] ? $param['type'] : "all";
        $this->examid = $examid;
        $data = Logic("BoxEdu", "Exam")->load($examid);
        $this->type = $type;
        $GLOBALS['marking'] = $data['marking']['right_answer'];
        $examquestions = $data['examsetting']['questype'];
        $this->examquestions = $examquestions;
        //dump($examquestions);
        $this->display();
    }

    /******显示选择题目**/
    public function show_questions($param)
    {
        $this->charactors = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
        $data = $param['data'];
        $key2 = $param['key2'];
								$examid=$param['examid'];
        $this->count_key = $key2;
        $this->type = I('type', "all");
        $data['user_answer'] = $GLOBALS['marking'][$data['questionid']];
        $type = $data['user_answer']['type'] ? $data['user_answer']['type'] : $this->type;
        $data['marking'] = $type . "_questions";
        $reload = $_GET['reload'];
        if ($reload != 1) {
            foreach ($data['questionanswer'] as $k => $one) {
                if (in_array($k, $data['user_answer']['answer'])) {
                    $data['questionanswer'][$k]['checked'] = "checked";
                }
            }
        }
								$this->examData=BoxModel("edu_exams")->where(array('examid'=>$examid))->find();
        $this->questions_data = $data;
        if (ACTION_NAME == "moni_jiexi" || $param['jiexi'] == 1) {
            $this->display("show_questions_jiexi");
        } else {
            $this->display("show_questions");
        }
    }

    /******显示分录题**/
    public function show_questions_5($data)
    {
        $data['user_answer'] = $GLOBALS['marking'][$data['questionid']];
        $this->type = I('type', "all");
        $type = $data['user_answer']['type'] ? $data['user_answer']['type'] : $this->type;
        $data['marking'] = $type . "_questions";
        $this->type = I('type');
        $this->questions_data_5 = $data;
        if (ACTION_NAME == "moni_jiexi") {
            $this->display("show_questions_5_jiexi");
        } else {
            $this->display("show_questions_5");
        }
    }

    /*******子题***/
    public function  sub_questions($pid)
    {
        $data = BoxModel("edu_questions")->get("questionparent='$pid' and questionstatus=1");
        $this->sub_questions_list = $data['list'];
        //dump($data);
        $this->display("Widget/sub_questions");
    }


}